package com.etime.shycourse.controller.coupons;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.config.PageMessage;
import com.etime.shycourse.dto.CouponlogDto;
import com.etime.shycourse.services.coupons.interfaces.CouponlogServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author wb
 * @since 2022-03-15
 */
@Api(tags = "后台-优惠券管理-使用记录日志")
@RestController
@RequestMapping("/sys/couponlog")
public class CouponlogController {
    @Autowired
    private CouponlogServices service;

    @ApiOperation("优惠券使用记录日志 分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "第几页"),
            @ApiImplicitParam(name = "pageSize", value = "每页多少行"),
            // 复用
            /** 优惠劵名模糊搜索 coupontitle
             * 优惠劵使用类型 couponlogtype
             * 优惠券使用时间 couponlogtime
             * 优惠券编号 couponno
             * */
            @ApiImplicitParam(name = "coupontitle", value = "可根据优惠劵名模糊搜索"),
            @ApiImplicitParam(name = "couponlogtype", value = "可根据优惠劵使用类型"),
    })
    @GetMapping("/page")
    public PageMessage<CouponlogDto> selectCouponUseLogPage(CouponlogDto dto, Long pageNum, Long pageSize) {
        PageMessage<CouponlogDto> msg = new PageMessage<>();
        Page<CouponlogDto> data = service.selectCouponUseLogPage(dto, pageNum, pageSize);
        if (data != null) {
            msg.setCode(1);
            msg.setPagedata(data);
        } else {
            msg.setCode(0);
            msg.setMsg("没有查询到数据");
        }
        return msg;
    }

}

